package DD.Game;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

public class GameMenu extends Activity implements OnClickListener {
	
	public static final String PREFS_NAME = "GameSettings";
	public static Typeface tf;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.mainmenu);
        
        tf = Typeface.createFromAsset(getAssets(),"data/fonts/floral.ttf");
        
        TextView tv = (TextView) findViewById(R.id.start);
        TextView tv1 = (TextView) findViewById(R.id.help);
        TextView tv2 = (TextView) findViewById(R.id.settings);
        TextView tv3 = (TextView) findViewById(R.id.about);
        TextView tv4 = (TextView) findViewById(R.id.exit);
        
        tv.setTypeface(tf);
        tv1.setTypeface(tf);
        tv2.setTypeface(tf);
        tv3.setTypeface(tf);
        tv4.setTypeface(tf);
        
        //tv.setOnTouchListener(new OnTouchListener());
        //tv1.setOnTouchListener(new OnTouchListener());
        //tv2.setOnTouchListener(new OnTouchListener());
        //tv3.setOnTouchListener(new OnTouchListener());
        //tv4.setOnTouchListener(new OnTouchListener());
        
        tv.setOnClickListener(this);
        tv1.setOnClickListener(this);
        tv2.setOnClickListener(this);
        tv3.setOnClickListener(this);
        tv4.setOnClickListener(this);        
	}
	

	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId())
		{
			case R.id.start:
			{
				Intent i = new Intent(this,Game.class);
				this.startActivity(i);
				break;
			}
			case R.id.settings:
			{
				Intent i = new Intent(this, SettingMenu.class);
				this.startActivity(i);
				break;
			}
			
			case R.id.help:
			{
				makeHelpDialog();
				break;
			}
			
			case R.id.about:
			{
				makeAboutDialog();
				break;
			}
			
			case R.id.exit:
			{
				this.finish();
				break;
			}
		}
	}
	
	private void makeAboutDialog() {		
		
	    AlertDialog.Builder dialog = new AlertDialog.Builder(this);	    
	    
	    dialog.setMessage("My Free Cell Game \n Version 1.0\n\nImplements by: \nLe Anh Tan \nTran Hoang Thinh");
	
	    dialog.setNegativeButton("Close", new DialogInterface.OnClickListener() {
	        public void onClick(DialogInterface arg0, int arg1) {}
	    });
	
	    dialog.show();
	}
	
	private void makeHelpDialog()
	{
		AlertDialog.Builder dialog = new AlertDialog.Builder(this);	    
	    
	    dialog.setMessage("How to play \n\nDraw cards from the bottom of each column and move them in the following ways:\n"+
	    		"From column to free cell. Only one card can occupy each free cell at a time."
	    		+"\nFrom column to column (or free cell to column). Cards must be placed on a column in descending sequential order, and alternating red and black"
	    		+"\nFrom column to home cell. Each stack must consist of a single suit, and start with an ace.");
	
	    dialog.setNegativeButton("Close", new DialogInterface.OnClickListener() {
	        public void onClick(DialogInterface arg0, int arg1) {}
	    });
	
	    dialog.show();
	}

}
